package top.hongthorn.controller;

import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import top.hongthorn.pojo.Time;
import top.hongthorn.service.TimeService;
import top.hongthorn.util.Result;
import java.util.Map;

/**
 * <p>
 * 时间&信息 前端控制器
 * </p>
 *
 * @author 泓宇网络科技工作室
 * @since 2023-12-28 00:47:55
 */
@RestController
@RequestMapping("/time")
@Api(value = "TimeController", tags = "TimeController")
public class TimeController {

    @Autowired
    private TimeService timeService;


    @ApiOperation(value = "删除时刻")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "id", dataType = "Integer", paramType = "query", required = true)
    })
    @RequestMapping(value = "/deleteByTimeId", method = RequestMethod.GET)
    public Result deleteByTimeId(Integer id) {
        return timeService.deleteByTimeId(id);
    }

    @ApiOperation(value = "数据分页")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page", value = "页码", dataType = "Integer", example = "1", required = false),
            @ApiImplicitParam(name = "limit", value = "显示条数", dataType = "Integer", example = "3", required = false),
    })
    @RequestMapping(value = "/findPage", method = RequestMethod.GET)
    public Map userPage(Integer page, Integer limit) {
        return timeService.findPage(page, limit);
    }

    @ApiOperation(value = "添加")
    @RequestMapping(value = "/addTime", method = RequestMethod.POST)
    public Result addTime(@ApiParam Time time) {
        return timeService.addTime(time);
    }


    @ApiOperation(value = "修改")
    @RequestMapping(value = "/updateTime", method = RequestMethod.POST)
    public Result updateTime(@ApiParam Time time) {
        return timeService.updateTime(time);
    }


}
